package com.yang.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;
/**
 * 描述：资源实体，菜单，按钮等
 * 版本：1.0
 * 作者： 杨建全
 * 创建时间：2016年3月24日  上午10:23:14
 */
@Entity
@Table(name = "t_resource")
public class Resource {
	private String id; // 编号
	private String name; // 资源名称
	private ResourceType type = ResourceType.menu; // 资源类型
	private String url; // 资源路径
	private String permission; // 权限字符串
	private String parentId; // 父编号
	private String parentIds; // 父编号列表
	private Boolean available = Boolean.FALSE;
	private String icon;	//菜单的图标
	
	@Id
	@GeneratedValue(generator = "uuid")
    @GenericGenerator(name = "uuid", strategy = "uuid")
	@Column(name = "rid", nullable = false, length = 9)
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@Column(name="name")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public ResourceType getType() {
		return type;
	}

	public void setType(ResourceType type) {
		this.type = type;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}
	@Column(name="permission_code")
	public String getPermission() {
		return permission;
	}

	public void setPermission(String permission) {
		this.permission = permission;
	}

	public String getParentId() {
		return parentId;
	}

	public void setParentId(String parentId) {
		this.parentId = parentId;
	}

	public String getParentIds() {
		return parentIds;
	}

	public void setParentIds(String parentIds) {
		this.parentIds = parentIds;
	}

	@Column(name="is_available")
	public Boolean getAvailable() {
		return available;
	}

	public void setAvailable(Boolean available) {
		this.available = available;
	}
	
	public String getIcon() {
		return icon;
	}

	public void setIcon(String icon) {
		this.icon = icon;
	}

	public static enum ResourceType {
		menu(0), button(1);

		private final int info;

		private ResourceType(int info) {
			this.info = info;
		}

		public int getInfo() {
			return info;
		}
	}

}
